package com.snailhd;

import com.alibaba.fastjson.JSON;
import com.snailhd.cloud.account.entity.UserDO;
import com.snailhd.cloud.account.spi.UserService;
import com.snailhd.cloud.redis.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@Slf4j
@RestController
@EnableDiscoveryClient
@SpringBootApplication
public class SnailhdAccountApplication {

	public static void main(String[] args) {
		SpringApplication.run(SnailhdAccountApplication.class, args);
	}

	@Resource
	RedisService redisService;

	@Reference(check = false)
    UserService userService;

	@GetMapping("/echo")
	public String echo(){
		UserDO accountDO = userService.queryById(121L);
		redisService.setex("com.snailhd.config",60*10,"hhhh");
		return "echo:"+redisService.get("com.snailhd.config")+"-->"+ JSON.toJSONString(accountDO);
	}
}
